#ifndef _L3DGECOMMS_H_
#define _L3DGECOMMS_H_
/*
 * L3DGEcomms library 1.1
 *
 *
 * This work has been made possible in part by a grant from the Cisco
 * University Research Program Fund at Community Foundation Silicon Valley.
 *
 * This software is copyright (c) 2007 Swinburne University of Technology,
 * Melbourne, Australia (CRICOS number 00111D).  This software was developed by
 * Lucas Parry (lparry@groupwise.swin.edu.au) while a reseach assistant at the
 * Centre for Advanced Internet Architectures (http://caia.swin.edu.au).
 *
 * This file is used by LRCD and Greymatter.
 *
 * L3DGEComms is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 * 
 * L3DGEComms is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  
 *
 * You should have received a copy of the GNU General Public License along with
 * L3DGEComms; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
 * Fifth Floor, Boston, MA  02110-1301  USA
 *
 * \author Lucas Parry - CAIA, Swinburne University of Technology
 */


#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <time.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include "debug.h"

#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>
#include <memory.h>


/*
 *  hash defines
 */
#define METRIC_ONE        (1)
#define METRIC_TWO        (2)
#define METRIC_THREE      (3)
#define METRIC_FOUR       (4)
#define METRIC_FIVE       (5)
#define METRIC_SIX        (6)
#define METRIC_SEVEN      (7)
#define METRIC_EIGHT      (8)
#define METRIC_NINE       (9)
#define METRIC_TEN        (10)
#define METRIC_ZERO       (0)

#define METRIC_SPIN           METRIC_ONE
#define METRIC_BOUNCE_HEIGHT  METRIC_TWO
#define METRIC_SCALE          METRIC_THREE
#define METRIC_ROLL           METRIC_FOUR
#define METRIC_COLOR          METRIC_FIVE
#define METRIC_BOUNCE_RATE    METRIC_SIX 
#define METRIC_SOUND          METRIC_SEVEN
#define METRIC_ALT_SKIN       METRIC_EIGHT
#define METRIC_ALT_MODEL      METRIC_NINE 
#define METRIC_UNUSED         METRIC_TEN
#define METRIC_INFO           METRIC_ZERO


#define FIELD_NAME        "n"
#define FIELD_VALUE       "v"
#define FIELD_RATE        "r"

/*
 * structs
 */
typedef struct actionlist_s {
  int messageNumber;
  int hostId;
  int weaponNumber;
  char *infodumpLines[10];
  struct actionlist_s *next;
}actionlist_t;

/*
 * extern variables
 */
extern pthread_mutex_t actionListMutex;
extern actionlist_t *actionListHead;
extern actionlist_t *actionListTail;

/*
 * function declerations
 */
void sendMessage(int hostid, int metric, char *field, char *value);
void setupComms(char *local_ip,int local_port,char *remote_ip,int remote_port);
void closeComms(void);
void setAsOutputDaemon(int i);
void deleteActionListItem(actionlist_t *tmp);
void sendFeedback(char *message);
void sendHostRepositionTrigger(int hosts[], int arraySize);

#endif
